package com.trainoo.payment.mock.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

/**
 * <p> add description here </p>
 *
 * @author tao.zhou
 * @version 1.0
 * @date 2023/6/6 15:43:00
 */
@Configuration
public class Config {

    public static final Integer WAIT = 0;
    public static final Integer SUCCESS = 1;

    @Value("${callback.result:1}")
    private Integer callbackResult;

    @Value("${callback.auto:false}")
    private Boolean autoCallback;

    @Value("${callback.sleepTime}")
    private Long sleepTime;

    @Value("${api.return.delay}")
    private Boolean delay;

    @Value("${api.return.delayTime}")
    private Long delayTime;

    // 自动回调黑名单（用于单独配置不自动回调的ip）
    private String blackList = "127.0.0.1;";

    public Integer getCallbackResult() {
        return callbackResult;
    }

    public void setCallbackResult(Integer callbackResult) {
        this.callbackResult = callbackResult;
    }

    public Boolean getAutoCallback() {
        return autoCallback;
    }

    public void setAutoCallback(Boolean autoCallback) {
        this.autoCallback = autoCallback;
    }

    public Long getSleepTime() {
        return sleepTime;
    }

    public void setSleepTime(Long sleepTime) {
        this.sleepTime = sleepTime;
    }

    public String getBlackList() {
        return blackList;
    }

    public void setBlackList(String blackList) {
        this.blackList = blackList;
    }

    public Boolean notInBlackList(String ip) {
        return !this.blackList.contains(ip);
    }

    public Boolean getDelay() {
        return delay;
    }

    public void setDelay(Boolean delay) {
        this.delay = delay;
    }

    public Long getDelayTime() {
        return delayTime;
    }

    public void setDelayTime(Long delayTime) {
        this.delayTime = delayTime;
    }
}
